*
* The item whose popover is currently open gets the .active
* style class.
+ *
+ * # Accessibility
+ *
+ * GtkPopoverMenuBar uses the #GTK_ACCESSIBLE_ROLE_MENU_BAR role,
+ * the menu items use the #GTK_ACCESSIBLE_ROLE_MENU_ITEM role and
+ * the menus use the #GTK_ACCESSIBLE_ROLE_MENU role.
*/
was_popup = FALSE;
if (was_popup && changed)
- gtk_popover_popdown (bar->active_item->popover);
+ {
+ gtk_accessible_update_state (GTK_ACCESSIBLE (bar->active_item),
+ GTK_ACCESSIBLE_STATE_EXPANDED, FALSE,
+ -1);
+ gtk_popover_popdown (bar->active_item->popover);
+ }
if (changed)
{
if (bar->active_item)
{
if (popup || (was_popup && changed))
- gtk_popover_popup (bar->active_item->popover);
+ {
+ gtk_popover_popup (bar->active_item->popover);
+ gtk_accessible_update_state (GTK_ACCESSIBLE (bar->active_item),
+ GTK_ACCESSIBLE_STATE_EXPANDED, FALSE,
+ -1);
+ }
else if (changed)
gtk_widget_grab_focus (GTK_WIDGET (bar->active_item));
}
set_active_item (bar, item, TRUE);
}
+static void
+gtk_popover_menu_bar_item_root (GtkWidget *widget)
+{
+ GtkPopoverMenuBarItem *item = GTK_POPOVER_MENU_BAR_ITEM (widget);
+
+ GTK_WIDGET_CLASS (gtk_popover_menu_bar_item_parent_class)->root (widget);
+
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (widget),
+ GTK_ACCESSIBLE_RELATION_LABELLED_BY, g_list_append (NULL, item->label),
+ GTK_ACCESSIBLE_RELATION_CONTROLS, g_list_append (NULL, item->popover),
+ -1);
+ gtk_accessible_update_property (GTK_ACCESSIBLE (widget),
+ GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE,
+ -1);
+}
+
static void
gtk_popover_menu_bar_item_class_init (GtkPopoverMenuBarItemClass *klass)
{
object_class->dispose = gtk_popover_menu_bar_item_dispose;
object_class->finalize = gtk_popover_menu_bar_item_finalize;
+ widget_class->root = gtk_popover_menu_bar_item_root;
widget_class->measure = gtk_popover_menu_bar_item_measure;
widget_class->size_allocate = gtk_popover_menu_bar_item_size_allocate;
G_TYPE_NONE, 0);
gtk_widget_class_set_css_name (widget_class, I_("item"));
+ gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_MENU_ITEM);
}
enum
{
toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
add_to_window (GTK_WINDOW (toplevel), bar);
+
+ gtk_accessible_update_property (GTK_ACCESSIBLE (bar),
+ GTK_ACCESSIBLE_PROPERTY_ORIENTATION, GTK_ORIENTATION_HORIZONTAL,
+ -1);
}
static void
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_css_name (widget_class, I_("menubar"));
+ gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_MENU_BAR);
}
static void